<?php require VIEWPATH . ADMIN_DIR . DIRECTORY_SEPARATOR . 'header.php' ?>
<style type="text/css">

</style>
<div class="page-header">
	<h1>课程表模板管理</h1>
</div>
<div class="col-xs-12">
	<div class="tabbable">
		<ul class="nav nav-tabs padding-18">
			<li class="active" id="this-week-tab">
				<a data-toggle="tab" href="#this-week" aria-expanded="true">
					<i class="green ace-icon fa fa-table bigger-120"></i> 本周课程表模板
				</a>
			</li>
			<li class="" id="next-week-tab">
				<a data-toggle="tab" href="#next-week" aria-expanded="false">
					<i class="orange ace-icon fa fa-table bigger-120"></i> 下周课程表模板
				</a>
			</li>
		</ul>
		<div class="tab-content no-border padding-24">
		<?php if(!empty($thisWeekArr)): ?>
			<div id="this-week" class="tab-pane active">
				<!-- 同步学校不可添加数据 -->
				<?php if(! $rmxSchool['school_from']): ?>
					<a href="<?= admin_url('schedule/save_schedule?this_week=1') ?>" class="btn btn-primary" data-toggle="modal">
						<i class="ace-icon fa fa-plus"></i> 添加模板
					</a>
				<?php endif ?>
				<table id="" class="table table-striped table-bordered table-hover" style="margin-top:10px">
					<thead>
						<tr>
							<th>编号</th>
							<th width="20%">标题</th>
							<th>年级</th>
							<th>每周上课天数</th>
							<th>上午节数</th>
							<th>下午节数</th>
							<th>上课时间</th>
							<!-- 同步学校不可修改或删除数据 -->
							<?php if(! $rmxSchool['school_from']): ?>
								<th>操作</th>
							<?php endif ?>
						</tr>
					</thead>
					<tbody>
						<?php foreach($thisWeekArr as $thisWeek): ?>
							<tr>
								<td><?= $thisWeek['id'] ?></td>
								<td><?= $thisWeek['schedule_title'] ?></td>
								<td><?= $thisWeek['grade_name'] ?></td>
								<td><?= $thisWeek['schedule_week_days'] ?></td>
								<td><?= $thisWeek['schedule_morning_number'] ?></td>
								<td><?= $thisWeek['schedule_afternoon_number'] ?></td>
								<td><a href="#modal-this-week-<?= $thisWeek['id'] ?>" data-toggle="modal"><i class="fa fa-gears"></i> 查看</a></td>
								<!-- 同步学校不可修改或删除数据 -->
								<?php if(! $rmxSchool['school_from']): ?>
									<td>
										<a href="<?= admin_url('schedule/save_schedule?this_week=1&id=' . $thisWeek['id']) ?>" class="text-success"><i class="fa fa-edit"></i> 编辑</a>
									</td>
								<?php endif ?>
							</tr>
							<div id="modal-this-week-<?= $thisWeek['id'] ?>" class="modal fade">
								<div class="modal-dialog">
									<div class="modal-content">
										<div class="modal-header no-padding">
											<div class="table-header">
												<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
													<span class="white">&times;</span>
												</button> <span id="school-name"></span>
												<?= $thisWeek['schedule_title'] ? $thisWeek['schedule_title'] : '编号：' . $thisWeek['id'] ?>
											</div>
										</div>
										<div class="modal-body no-padding">
											<div class="row">
												<div>
													<?php if(isset($thisWeek['timeArr']) && !empty($thisWeek['timeArr'])): ?>
														<?php foreach($thisWeek['timeArr'] as $time): ?>
															<div style="text-align:center;font-size: 16px;line-height:28px;margin:10px 0;">
																<span>第<?= $time['timeslotInDay'] ?>节：</span>
																&nbsp;&nbsp;
																<span>
																	<?= $time['beginTime'] ?>
																	—
																	<?= $time['endTime'] ?>
																</span>
															</div>
														<?php endforeach ?>
													<?php else: ?>
														<div style="text-align:center;margin-top: 20px;margin-bottom: 40px;color: #D80000;" class="text-danger"><h4>暂无上课时间，请前往添加</h4></div>
													<?php endif ?>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>	
						<?php endforeach ?>
					</tbody>
				</table>
			</div>
		<?php else: ?>
			<div id="this-week" class="tab-pane active">
				<!-- 同步学校不可添加数据 -->
				<?php if(! $rmxSchool['school_from']): ?>
					<a href="<?= admin_url('schedule/save_schedule?this_week=1') ?>" class="btn btn-primary" data-toggle="modal">
						<i class="ace-icon fa fa-plus"></i> 添加模板
					</a>
				<?php endif ?>
				<h3 style="color: #9D9D9D;">暂无本周模板</h3>
			</div>
		<?php endif ?>
		<?php if(!empty($nextWeekArr)): ?>
			<div id="next-week" class="tab-pane">
				<!-- 同步学校不可添加数据 -->
				<?php if(! $rmxSchool['school_from']): ?>
					<a href="<?= admin_url('schedule/save_schedule?this_week=0') ?>" class="btn btn-primary" data-toggle="modal">
						<i class="ace-icon fa fa-plus"></i> 添加模板
					</a>
				<?php endif ?>
				<table id="" class="table table-striped table-bordered table-hover" style="margin-top:10px">
					<thead>
						<tr>
							<th>编号</th>
							<th width="20%">标题</th>
							<th>年级</th>
							<th>每周上课天数</th>
							<th>上午节数</th>
							<th>下午节数</th>
							<th>上课时间</th>
							<!-- 同步学校不可修改或删除数据 -->
							<?php if(! $rmxSchool['school_from']): ?>
								<th>操作</th>
							<?php endif ?>
						</tr>
					</thead>
					<tbody>
						<?php foreach($nextWeekArr as $nextWeek): ?>
							<tr>
								<td><?= $nextWeek['id'] ?></td>
								<td><?= $nextWeek['schedule_title'] ?></td>
								<td><?= $nextWeek['grade_name'] ?></td>
								<td><?= $nextWeek['schedule_week_days'] ?></td>
								<td><?= $nextWeek['schedule_morning_number'] ?></td>
								<td><?= $nextWeek['schedule_afternoon_number'] ?></td>
								<td><a href="#modal-next-week-<?= $nextWeek['id'] ?>" data-toggle="modal"><i class="fa fa-gears"></i> 查看</a></td>
								<!-- 同步学校不可修改或删除数据 -->
								<?php if(! $rmxSchool['school_from']): ?>
									<td>
										<a href="<?= admin_url('schedule/save_schedule?this_week=0&id=' . $nextWeek['id']) ?>" class="text-success"><i class="fa fa-edit"></i> 编辑</a>
									</td>
								<?php endif ?>
							</tr>
							<div id="modal-next-week-<?= $nextWeek['id'] ?>" class="modal fade">
								<div class="modal-dialog">
									<div class="modal-content">
										<div class="modal-header no-padding">
											<div class="table-header">
												<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
													<span class="white">&times;</span>
												</button> <span id="school-name"></span>
												<?= $nextWeek['schedule_title'] ? $nextWeek['schedule_title'] : '编号：' . $nextWeek['id'] ?>
											</div>
										</div>
										<div class="modal-body no-padding">
											<div class="row">
												<div>
													<?php if(isset($nextWeek['timeArr']) && !empty($nextWeek['timeArr'])): ?>
														<?php foreach($nextWeek['timeArr'] as $time): ?>
															<div style="text-align:center;font-size: 16px;line-height:28px;margin:10px 0;">
																<span>第<?= $time['timeslotInDay'] ?>节：</span>
																&nbsp;&nbsp;
																<span>
																	<?= $time['beginTime'] ?>
																	—
																	<?= $time['endTime'] ?>
																</span>
															</div>
														<?php endforeach ?>
													<?php else: ?>
														<div style="text-align:center;margin-top: 20px;margin-bottom: 40px;color: #D80000;" class="text-danger"><h4>暂无上课时间，请前往添加</h4></div>
													<?php endif ?>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						<?php endforeach ?>
					</tbody>
				</table>
			</div>
		<?php else: ?>
			<div id="next-week" class="tab-pane">
				<?php if(! $rmxSchool['school_from']): ?>
					<a href="<?= admin_url('schedule/save_schedule?this_week=0') ?>" class="btn btn-primary" data-toggle="modal">
						<i class="ace-icon fa fa-plus"></i> 添加模板
					</a>
				<?php endif ?>
				<h3 style="color: #9D9D9D;">暂无下周模板</h3>
			</div>
		<?php endif ?>
		</div>
	</div>
</div>

<?php require VIEWPATH. ADMIN_DIR. DIRECTORY_SEPARATOR. 'footer.php'?>
<script type="text/javascript">
	$(function(){
		// 是否选择下周模板tab
		<?php if(isset($selectNextTab) && $selectNextTab == 1): ?>
				$("#this-week").removeClass('active');
				$("#next-week").addClass('active');
				$("#this-week-tab").removeClass('active');
				$("#next-week-tab").addClass('active');
		<?php endif ?>	
	})
</script>